<!DOCTYPE HTML>
<html>

<head>
    <title>原生h5实现拖拽</title>
    <style type="text/css">
        #div1 {
            width: 300px;
            height: 300px;
            padding: 10px;
            border: 1px solid #aaaaaa;
        }
        #div2 {
            width: 100px;
            height: 100px;
            padding: 10px;
            border: 1px solid #888888;
        }
    </style>
    <script type="text/javascript">
        function allowDrop(ev) {
            ev.preventDefault();
        }

        function drag(ev) {
            console.log(ev);
            
        }

        function drop(ev) {
            ev.preventDefault();
            var data = ev.dataTransfer.getData("Text");
            ev.target.appendChild(document.getElementById(data));
        }
    </script>
</head>

<body>

    <p>请把 W3School 的图片拖放到矩形中：</p>

    <div id="div1"></div>
    <br />
    <div id="div2" draggable="true"></div>

</body>

</html>